package com.example.gaojt.androiddemo.myDraw;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by gaojt on 7/19/17.
 */

public class MyDrawView extends View {


    private Paint mPaint;

    public MyDrawView(Context context) {
        this(context,null);
    }

    public MyDrawView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public MyDrawView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mPaint = new Paint();
        mPaint.setColor(Color.RED);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        int x1 = 0;
        int y1 = 300;
        int x2 = 400;
        int y2 = 0;
        int centerX = 200;
        int centerY = 150;

        canvas.drawLine(x1,y1,x2,y2,mPaint);
    }
}
